package com.five.sbgroup5job.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.five.sbgroup5job.entity.sst;
import com.five.sbgroup5job.mapper.StatisticMapper;
import com.five.sbgroup5job.service.StatisticService;
import com.five.sbgroup5job.vo.StatisticVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
* @author hujinru
* @description 针对表【buy】的数据库操作Service实现
* @createDate 2024-11-08 11:13:10
*/
@Service
public class StatisticServiceImpl extends ServiceImpl<StatisticMapper, sst>
    implements StatisticService {
    @Resource
    private StatisticMapper statisticMapper;

    @Override
    public List<sst> statisticlist() {
        return statisticMapper.selectList(null);
    }

    @Override
    public String statisticAdd(StatisticVo statisticVo) {
        sst sst = new sst();
        sst.setName(statisticVo.getName());
        sst.setQuantity(statisticVo.getQuantity());
        sst.setPrice(statisticVo.getPrice());
        sst.setTotal(statisticVo.getTotal());
        int result = statisticMapper.insert(sst);
        if (result >0) {
            return "添加成功";
        }else {
            return "添加失败";
        }
    }
    @Override
    public String statisticUpdate(StatisticVo statisticVo) {
        sst sst = new sst();
        sst.setId(statisticVo.getId());
        sst.setName(statisticVo.getName());
        int result = statisticMapper.updateById(sst);
        if (result > 0) {
           return "修改成功";
        } else {
            return "修改失败";
        }

    }
    //删除
    @Override
    public String statisticDelete(StatisticVo statisticVo) {
        int result = statisticMapper.deleteById(statisticVo.getId());
        if (result > 0) {
            return "删除成功";
        } else {
            return "删除失败";
        }
    }


}




